﻿import odal.*;
class odal.OMSStructure extends OMSNode {
	private var m_rootElement:OMSElement;
	private var ROOT_ELEMENT_NAME:String = "VirtualRoot";
	private var ROOT_NAMESPACE_PATH:String = "/omscube";
	private var ROOT_SCHEME:String = "Container";
	private var ROOT_ATTRIBUTE:String = "objects";
	private var m_OmsData:OMSData;
	private var m_aElements:Array;
	private var m_ElementsById:Object;
	private var m_ElementsByBookmark:Object;
	
	public function OMSStructure( p_omsData:OMSData ) {
		this.m_aElements = new Array();
		this.m_ElementsById = new Object();
		this.m_ElementsByBookmark = new Object();
		this.m_OmsData = p_omsData;
		this.m_id = 0;
		this.m_name = 'OMSStructure';
		this._createRoot();
	}//OMSStructure
	
	private function _createRoot( ){
		this.m_rootElement = null;
		this.m_rootElement = new OMSElement( this, 0, this.ROOT_ELEMENT_NAME, this.ROOT_ELEMENT_NAME, this.ROOT_SCHEME, this.ROOT_NAMESPACE_PATH );
	}//_createRoot
	
	public function get Root():OMSElement {
		return this.m_rootElement;
	}//get Root
	
	public function addElement( p_element:OMSElement ) {
//		trace( 'addElement' );
		this.m_aElements.push( p_element );
		this.m_ElementsById[ p_element.Id ] = p_element;
		this.m_ElementsByBookmark[ p_element.Bookmark ] = p_element;
	}//addElement
	
	public function get Elements():Array {
//		trace( 'get Elements: ' + this.m_aElements.length );
		return this.m_aElements;
	}//get Elements
	
	public function getElementById( p_id:String ):OMSElement {
		return this.m_ElementsById[ p_id ];
	}//getElementById
	
	public function getElementByBookmark( p_bookmark:String ):OMSElement {
		return this.m_ElementsByBookmark[ p_bookmark ];
	}//getElementById
	
}//odal.OMSStructure